/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package miage.entities;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author TnP
 */
@Entity
@Table(name = "magasin")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Magasin.findAll", query = "SELECT m FROM Magasin m"),
    @NamedQuery(name = "Magasin.findByIbanStore", query = "SELECT m FROM Magasin m WHERE m.ibanStore = :ibanStore"),
    @NamedQuery(name = "Magasin.findByNomStore", query = "SELECT m FROM Magasin m WHERE m.nomStore = :nomStore"),
    @NamedQuery(name = "Magasin.findByReferenceStore", query = "SELECT m FROM Magasin m WHERE m.referenceStore = :referenceStore"),
    @NamedQuery(name = "Magasin.findBySolde", query = "SELECT m FROM Magasin m WHERE m.solde = :solde"),
    @NamedQuery(name = "Magasin.findByAdresseStore", query = "SELECT m FROM Magasin m WHERE m.adresseStore = :adresseStore"),
    @NamedQuery(name = "Magasin.findByCodepostalStore", query = "SELECT m FROM Magasin m WHERE m.codepostalStore = :codepostalStore"),
    @NamedQuery(name = "Magasin.findByVilleStore", query = "SELECT m FROM Magasin m WHERE m.villeStore = :villeStore")})
public class Magasin implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 27)
    @Column(name = "iban_store")
    private String ibanStore;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 25)
    @Column(name = "nom_store")
    private String nomStore;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 10)
    @Column(name = "reference_store")
    private String referenceStore;
    @Basic(optional = false)
    @NotNull
    @Column(name = "solde")
    private double solde;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 50)
    @Column(name = "adresse_store")
    private String adresseStore;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 10)
    @Column(name = "codepostal_store")
    private String codepostalStore;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 25)
    @Column(name = "ville_store")
    private String villeStore;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "referenceStore")
    private Collection<Produit> produitCollection;

    public Magasin() {
    }

    public Magasin(String ibanStore) {
        this.ibanStore = ibanStore;
    }

    public Magasin(String ibanStore, String nomStore, String referenceStore, double solde, String adresseStore, String codepostalStore, String villeStore) {
        this.ibanStore = ibanStore;
        this.nomStore = nomStore;
        this.referenceStore = referenceStore;
        this.solde = solde;
        this.adresseStore = adresseStore;
        this.codepostalStore = codepostalStore;
        this.villeStore = villeStore;
    }

    public String getIbanStore() {
        return ibanStore;
    }

    public void setIbanStore(String ibanStore) {
        this.ibanStore = ibanStore;
    }

    public String getNomStore() {
        return nomStore;
    }

    public void setNomStore(String nomStore) {
        this.nomStore = nomStore;
    }

    public String getReferenceStore() {
        return referenceStore;
    }

    public void setReferenceStore(String referenceStore) {
        this.referenceStore = referenceStore;
    }

    public double getSolde() {
        return solde;
    }

    public void setSolde(double solde) {
        this.solde = solde;
    }

    public String getAdresseStore() {
        return adresseStore;
    }

    public void setAdresseStore(String adresseStore) {
        this.adresseStore = adresseStore;
    }

    public String getCodepostalStore() {
        return codepostalStore;
    }

    public void setCodepostalStore(String codepostalStore) {
        this.codepostalStore = codepostalStore;
    }

    public String getVilleStore() {
        return villeStore;
    }

    public void setVilleStore(String villeStore) {
        this.villeStore = villeStore;
    }

    @XmlTransient
    public Collection<Produit> getProduitCollection() {
        return produitCollection;
    }

    public void setProduitCollection(Collection<Produit> produitCollection) {
        this.produitCollection = produitCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (ibanStore != null ? ibanStore.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Magasin)) {
            return false;
        }
        Magasin other = (Magasin) object;
        if ((this.ibanStore == null && other.ibanStore != null) || (this.ibanStore != null && !this.ibanStore.equals(other.ibanStore))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "miage.entities.Magasin[ ibanStore=" + ibanStore + " ]";
    }
    
}
